﻿<div class="col mt-2">
    <div class="@GetClass()" @onclick="() => Book.Selected = !Book.Selected">
        <div class="card-header" style="font-weight: bold;">
            <!-- input type="checkbox" class="mx-3"/ -->
            @Book.Mfn
        </div>
        <BeriCover Number="@Book.Cover" />
        <div class="card-body">
            <span class="card-text">
                @Book.Description
            </span>
        </div>
    </div>
</div>

@code
{
    [Parameter]
    public BookInfo Book { get; set; } = null!;

    private string GetClass()
    {
        var result = "card border-info";

        // ReSharper disable ConditionIsAlwaysTrueOrFalse
        if (Book is null)
        {
            return result + " bg-danger";
        }
        // ReSharper restore ConditionIsAlwaysTrueOrFalse

        return result +
            (
                Book.Selected ? " bg-secondary" : ""
            );
    }
}
